package com.schoolvisitors.controller.user;

import com.schoolvisitors.response.ResultBody;
import com.schoolvisitors.response.ResultCode;
import com.schoolvisitors.service.ImgService;
import org.apache.commons.io.FilenameUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import static com.schoolvisitors.utils.FileUtil.getMultipartFileMd5;

@RestController
@RequestMapping("/api/v1/user")
public class UserImgController {
    private final ImgService imgService;

    public UserImgController(ImgService imgService) {
        this.imgService = imgService;
    }

    @PostMapping("/uploadImg")
    public ResultBody uploadImage(@RequestParam("file") MultipartFile file) {
        return imgService.uploadByImg(file);
    }



}
